package tsing.javase.util;

import java.util.ArrayList;
import java.util.List;

/**
 * @Date 7/8/2023 上午9:11
 */
public class ListUtils {
    public static void main(String[] args) {
/*        try {
            String s = String.class.newInstance();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }*/


        int  i = 2001;

        int i1 = i / 1000;
        int count =  1;
        if(i1>0){
           count =  i1+1;
        }

        System.out.println(count);

    }


    /**
     * 集合分堆
     * @param list ：原集合
     * @param n  ：分堆个数
     * @param <T>
     * @return  分堆后的List集合
     */
    public static  <T> List<List<T>>averageAssign(List<T>list,int n){
        List<List<T>>result = new ArrayList<>();
        if(list ==null){
            System.out.println("list is null ,Throws Exception");
        }else{
            // 商
            int i = list.size() / n;
            // 余数
            int r = list.size() % n ;
            // 偏移量
            int offset = 0;
            for (int j = 1; j <= n ; j++) {
                List<T> objects;
                if(r>0){
                   objects = list.subList((j - 1) * i +offset, j * i+offset+1);
                    r --;
                    offset++;
                }else{
                    objects = list.subList((j - 1) * i+offset, j*i+offset);
                }
                result.add(objects);
            }
        }
        return result;
    }
}
